<?php

class UserModule extends CWebModule
{
    protected static $_guest,$_admin;
    public $avatar;

	public function init()
	{
        $this->setImport(array(
            'application.modules.user.models.*',
            'application.modules.user.components.*',
        ));

        $this->setParams(array(
                'adminEmail'=>'shandyrov@gmail.com',
                'adminEmailPass'=>'askar1983zhakon1987diasik2012',
                'mailDomain'=>'gmail.com',
                'defaultAvatar'=>'noavatar.png',
                'avatar'=>'/../protected/modules/user/images/avatar/')
        );
        $this->setLayoutPath(Yii::getPathOfAlias('themes.twitter.views.layouts'));
	}

    public function install()
    {
        Yii::app()->config->add(array(
            array(
                'param'=>'BLOG.POSTS_PER_PAGE',
                'label'=>'Записей на странице',
                'value'=>'10',
                'type'=>'string',
                'default'=>'10',
            ),
            array(
                'param'=>'BLOG.POSTS_PER_HOME',
                'label'=>'Записей на главной странице',
                'value'=>'5',
                'type'=>'string',
                'default'=>'5',
            ),
        ));

        $path = Yii::getPathOfAlias('webroot.upload.blog');

        if (!is_dir($path))
            @mkdir($path, 755);
    }

    public function uninstall()
    {
        Yii::app()->config->delete(array(
            'BLOG.POSTS_PER_PAGE',
            'BLOG.POSTS_PER_HOME',
        ));
    }

	public function beforeControllerAction($controller, $action)
	{
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module publiccontroller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}


    public function getUrlRules()
    {
        return array(
            '/usersite/index/login'=>'/user/frontend/login',
            '/user/registration'=>'/user/frontend/registration',
            '/user/registration/success'=>'/user/frontend/success',
            'user/activation'=>'/user/frontend/activation',
            '/user/activation/success'=>'/user/frontend/success',
            '/user/logout'=>'/user/frontend/logout',
        );
    }



}
